<?
class Common_model extends Model{

	function Common_model(){
		parent::Model();
		$l = get_cookie('language')?get_cookie('language'):$this->config->item('language');				
		if($this->input->post('hidden_change_language')){
			$l = $this->input->post('hidden_change_language');
			set_cookie('language',$l,0,'','/','');
			redirect(uri_string(),'location');
		}
		if(!get_cookie('language')){
			set_cookie('language',$l,0,'','/','');
		}		
		$this->lang->load('backend',$l);
	}		
	function checklogin(){		
		if(FALSE===get_cookie('username_admin')){					
			redirect('','location');
			exit();
		}
		$query = $this->db->get_where('users',array('username'=>get_cookie('username_admin')));
		$time_exp = $query->row();
		if(get_cookie('username_admin')=='' || time()-$time_exp->time_expire>1800){
			delete_cookie("username_admin");
			redirect('','location');		
			exit();
		}
		else{
			$this->db->where('username',get_cookie('username_admin'));
			$this->db->update('users',array('time_expire'=>time()));
		}		
	}	
	function general(){			
		$data['webtitle'] = 'Phuc Thinh - System Admin';
		return $data;    
	}
}

/* End of file common_model.php */
/* Location: ./system/application/admin/controllers/common_model.php */